<%@ page import="com.jkd.model.pojo.Student" %>
<%@ page import="com.jkd.service.IDisciplineService" %>
<%@ page import="com.jkd.service.impl.DisciplineServiceImpl" %>
<%@ page import="com.jkd.model.pojo.Discipline" %><%--
  Created by IntelliJ IDEA.
  User: admin
  Date: 2021/4/23
  Time: 7:57
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
    <title>用户个人信息</title>
    <link rel="stylesheet" href="/jkd/plugins/layui/css/layui.css">
    <link rel="stylesheet" href="/jkd/plugins/bootstrap/css/bootstrap.min.css">
</head>
<body>
<%@ include file="../nav/nav.jsp"%>
<blockquote class="layui-elem-quote layui-text">
  用户完善个人信息
</blockquote>

<fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
    <legend>个人信息</legend>
</fieldset>
<div class="layui-container">
    <div class="layui-row">
        <div class="layui-col-md1" style="height: 420px;background-color: #F2F2F2"></div>
        <div class="layui-col-md6 " style="height: 420px;background-color:#F2F2F2;opacity: 0.7;background-image: url('/jkd/images/info.jpg');text-align: center; color: #FFFF00">
            <br/>
            <br/>
            <br/>
            <h1>完善信息的注意点:</h1>
            <h3>用户需要按照真实情况填写数据</h3>
            <h3>填写时信息不能为空</h3>
        </div>
        <div class="layui-col-md1" style="height: 420px;background-color: #F2F2F2"></div>
        <div class="layui-col-md4 " style="background-color: #FAFAFA;height: 420px">
            <form class="layui-form "  style="margin-top:10px">
                <div class="layui-inline">
                    <label class="layui-form-label">专业</label>
                    <div class="layui-input-inline">
<%--                        <%--%>
<%--                            HttpSession session1 = request.getSession();--%>
<%--                            Student student = (Student) session1.getAttribute("student");--%>
<%--                            IDisciplineService iDisciplineService = new DisciplineServiceImpl();--%>
<%--                            Discipline discipline = iDisciplineService.selectById(student.getDisciplineId());--%>
<%--                            String name = discipline.getDisciplineName();--%>
<%--                            request.setAttribute("disciplineName",name);--%>
<%--                        %>--%>
                        <select name="disc" lay-verify="required" lay-search="" id="discipline" >
                            <option value=""></option>
                            <c:forEach items="${discipline}" var="d">
                            <option value="${d.disciplineId}">${d.disciplineName}</option>
                            </c:forEach>
                        </select>
                    </div>
                </div>

        <div class="layui-form-item">
            <label class="layui-form-label">年级</label>
            <div class="layui-input-block">
                <input type="text" name="grade" value="${student.grade}"  placeholder="请输入" autocomplete="off" class="layui-input" style="width: 180px" id="grade">
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">姓名</label>
            <div class="layui-input-block">
                <input type="text" name="name" value="${student.name}" placeholder="请输入" autocomplete="off" class="layui-input" style="width: 180px" id="name">
            </div>
        </div>

        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label">性别</label>
                <div class="layui-input-block" >
                    <input type="radio" name="sex" value="男" title="男" checked="" id="man">
                    <input type="radio" name="sex" value="女" title="女" id="women">
                </div>
            </div>

            <div class="layui-inline">
                <label class="layui-form-label">电话</label>
                <div class="layui-input-inline">
                    <input type="tel" name="cel" value="${student.cel}" autocomplete="off" class="layui-input" id="cel">
                </div>
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">具体地址</label>
            <div class="layui-input-block">
                <input type="text" name="location"  value="${student.location}" placeholder="请输入" autocomplete="off" class="layui-input" style="width: 180px" id="location">
            </div>
        </div>

        <div class="layui-form-item">
            <div class="layui-input-block">
                <button type="button" class="layui-btn" lay-submit="" lay-filter="demo1" onclick="charge()">立即提交</button>
                <button type="reset" class="layui-btn layui-btn-primary">重置</button>
            </div>
        </div>
        </form>
        </div>
    </div>
    <script>
        function charge() {
            let discipline = document.getElementById("discipline").value;
            let grade = document.getElementById("grade").value;
            let name = document.getElementById("name").value;
            let sex =  document.getElementsByName("sex").values();
            let cel = document.getElementById("cel").value;
            let location = document.getElementById("location").value;
         $.post('/jkd/service/student/update',{"discipline":discipline,"grade":grade,"name":name,"sex":sex,"cel":cel,"location":location},function (data) {
             console.log(data);
             let result = data.result;
            <%--alert(<%=result%>);--%>
<%--             <%--%>
<%--            --%>
<%--             %>--%>
             if(data.code == "200"){
                 window.location = '/jkd/service/student/echo';
                 alert("添加成功！");

             }
             if(data.code =="500"){
                 alert("添加失败！");
             }
         })
        }
    </script>
</div>
<script src="/jkd/plugins/jquery/jquery.min.js"></script>
<script src="/jkd/plugins/bootstrap/js/bootstrap.min.js"></script>
<script src="/jkd/plugins/layui/layui.js"></script>
</body>
</html>
